package com.jun.rabbitmq.producer.config;

import com.jun.common.rabbitmq.constant.ExchangeConstant;
import com.jun.common.rabbitmq.constant.QueueConstant;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author yuejun.li
 * @date 2024/4/18 14:35:01
 */
@Configuration
public class FanoutRabbitConfig {

    @Bean
    public Queue queueA() {
        return new Queue(QueueConstant.FANOUT_A);
    }

    @Bean
    public Queue queueB() {
        return new Queue(QueueConstant.FANOUT_B);
    }

    @Bean
    public Queue queueC() {
        return new Queue(QueueConstant.FANOUT_C);
    }

    @Bean
    public FanoutExchange fanoutExchange() {
        return new FanoutExchange(ExchangeConstant.FANOUT_EXCHANGE);
    }

    @Bean
    public Binding bindingExchangeA() {
        return BindingBuilder.bind(queueA()).to(fanoutExchange());
    }

    @Bean
    public Binding bindingExchangeB() {
        return BindingBuilder.bind(queueB()).to(fanoutExchange());
    }

    @Bean
    public Binding bindingExchangeC() {
        return BindingBuilder.bind(queueC()).to(fanoutExchange());
    }
}
